{{- range $key, $value := .CandiVersionMap.k8s }}
  {{- $version := toString $key }}
  {{- if $value.ccm.gcp }}
---
image: {{ $.ModuleName }}/{{ $.ImageName }}-{{ $version | replace "." "-" }}
fromImage: common/distroless
import:
  - artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    add: /src/gcp-cloud-controller-manager
    to: /usr/local/bin/cloud-controller-manager
    before: setup
docker:
  ENTRYPOINT: ["/usr/local/bin/cloud-controller-manager"]
---
artifact: {{ $.ModuleName }}/{{ $.ImageName }}-artifact-{{ $version | replace "." "-" }}
    {{- if semverCompare ">=1.29" $version }}
from: {{ $.Images.BASE_GOLANG_21_ALPINE }}
    {{- else if semverCompare ">=1.27" $version }}
from: {{ $.Images.BASE_GOLANG_20_ALPINE }}
    {{- else if semverCompare ">=1.25" $version }}
from: {{ $.Images.BASE_GOLANG_19_ALPINE }}
    {{- end }}
mount:
- fromPath: ~/go-pkg-cache
  to: /go/pkg
shell:
  beforeInstall:
    - apk add --no-cache make bash git mercurial patch rsync
  install:
    - mkdir /src
    - wget https://github.com/kubernetes/cloud-provider-gcp/archive/{{ $value.ccm.gcp }}.tar.gz -O - | tar -xz --strip-components=1 -C /src/
    - cd /src
      {{- if semverCompare "<=1.22" $version }}
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o gcp-cloud-controller-manager cmd/cloud-controller-manager/main.go
      {{- else if semverCompare ">=1.26" $version }}
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o gcp-cloud-controller-manager cmd/cloud-controller-manager/main.go cmd/cloud-controller-manager/nodeipamcontroller.go cmd/cloud-controller-manager/gkenetworkparamsetcontroller.go
      {{- else }}
    - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o gcp-cloud-controller-manager cmd/cloud-controller-manager/main.go cmd/cloud-controller-manager/nodeipamcontroller.go
      {{- end }}
    - chown 64535:64535 /src/gcp-cloud-controller-manager
    - chmod 0755 /src/gcp-cloud-controller-manager
  {{- end }}
{{- end }}
